package cn.tedu.carehome.foundation.controller;

import cn.tedu.carehome.foundation.pojo.dto.CallAddNewDTO;
import cn.tedu.carehome.foundation.pojo.dto.CallLoginDTO;
import cn.tedu.carehome.foundation.pojo.vo.CallListItemVO;
import cn.tedu.carehome.foundation.security.LoginPrincipal;
import cn.tedu.carehome.foundation.service.ICallService;
import cn.tedu.carehome.foundation.service.IStaffService;
import cn.tedu.carehome.foundation.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;
import java.util.List;

@RestController
@Slf4j
@Api(tags = "报警查询")
@Validated
@RequestMapping("/call")
public class CallController {

    public CallController(){
        log.debug("创建控制类对象:CallController");
    }
    @Autowired
    private ICallService callService;

    @ApiOperation("根据id关闭报警信息")
    @PostMapping("/{id:[0-9]+}/delete")
    public JsonResult<Void> delete(@PathVariable Long id) {
        log.debug("开始处理【根据id关闭报警信息】的请求，参数：{}", id);
        callService.deleteById(id);
        return JsonResult.ok();
    }

    @ApiOperation("查询报警信息列表")
    @GetMapping("")
    public JsonResult<List<CallListItemVO>> list() {
        List<CallListItemVO> list = callService.list();
        return JsonResult.ok(list);
    }

    @ApiOperation("查询报警信息列表")
    @GetMapping("/list")
    public List<CallListItemVO> listplus() {
        List<CallListItemVO> list = callService.list();
        return list;
    }


}
